<!--结算单入录-->
<template>
  <div class="contain">
    <div class="order-detail-top">
      <div class="order-detail-header">
        <span class="f-l">结算单号：<i>{{todolist.SettleBillNo}}</i></span>
      </div>
      <ul class="order-detail-info">        
        <li class="displayflex">
          <label>结算时间</label>
          <p class="flex1">{{todolist.SettleDate | timeshort}}</p>
        </li>
        <li class="displayflex">
          <label>结算单位</label>
          <p class="flex1">{{todolist.SettleCorpName}}</p>
        </li>
        <li class="displayflex">
          <label>总金额</label>
          <p class="flex1">{{todolist.Amount}}元</p>
        </li>
      </ul>      
    </div>
    <div class="order-detail-flor" v-for="item in tododetail">
      <div class="order-no cf">
        <p class="f-l">业务单据：{{item.MVBillNo}}</p>
      </div>
      <div class="displayflex od-contain">
        <div class="od-contain-lf"><img :src="item.PictContent | filterImgUrl"></div>
        <div class="od-contain-rit">
          <p>{{item.GoodsName}}</p>
          <span>{{item.GoodsSpec}}</span>
          <span>共{{item.Qty}}盒</span>
          <span>合计:{{item.Amount}}元 </span>
        </div>
        <div class="check-wrap">
          <label class="mint-checklist-label">
            <span class="mint-checkbox">
              <input type="checkbox"  class="mint-checkbox-input"  v-model="checkItem" v-bind:value="item" @change="iptClick(item)"> 
              <span class="mint-checkbox-core"></span>
            </span>
          </label>
        </div>
      </div>
    </div>
    <!--footer-->
    <div class="checknum-bot displayflex">
      <div class="cf">
        <div class="num f-l">已选<em class="red">{{selectAmount}}</em>元</div>
      </div>
      <div class="flex1">
        <ul class="cf cn-btn-grp f-r">
          <li class="btn-checknum f-l" @click="toEnter()">录发票</li>
        </ul>
      </div>
    </div>
    <!--footer-->
  </div>
</template>

<script>

export default {
  name:'statementChoice',
  data() {
    return {
      todolist: [],
      tododetail: [],
      checkItem: [],
      selectAmount: 0,
    }
  },
  mounted() {
    this.$nextTick(function() {
      this.getData();
    })
  },
  methods: {
    getData: function() {
      var userinfo = JSON.parse(localStorage.userinfo);
      this.todolist = JSON.parse(sessionStorage.items);
      var query = {
          GUID: this.todolist.Guid,
      };
      var _this = this;
      this.Ajax.post('getSettleDetail',query).then(function(resp){
          _this.tododetail = resp.Datas;
      });
    },
    iptClick: function(item) {
      if (item.checkrow) {
        if (item.Amount > 0) {
          this.selectAmount -= item.Amount;
        }
        item.checkrow = false;
      } else {
        this.selectAmount += item.Amount;
        item.checkrow = true;
      }
    },
    toEnter: function() {
      sessionStorage.Selectitems = JSON.stringify(this.checkItem);
      sessionStorage.Amount = this.selectAmount;
      this.$router.push({
          path: '/order/statementConfirm'
      });
    }
  }
}
</script>